<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        // 这是一个json格式的字符串
        // var personStr ='{"name":"张三","age":"10","dog":{"name":"小花"},"loveSingers":["周杰伦","林俊杰","陈奕迅"],"firends":[{"fname":"李四","age":"20"},{"fname":"王五","age":"19"},{"fname":"阎王","age":"23"}]}'
//   console.log(personStr)
//   console.log(typeof personStr) // string
//   console.log(personStr.length)
//   console.log(personStr.name)

// json字符串转化为对象
//   var person = JSON.parse(personStr)
//   console.log(personStr)
//   console.log(person)


var person={
    'name':'张小明',
    'age':20,
    'girlFriend':{
        'name':'铁铃',
        'age':23
    },
    'foods':['苹果','香蕉','橘子','葡萄'],
    'pets':[
        {
            'petName':'大黄',
            'petType':'dog'
        },
        {
            'petName':'小花',
            'petType':'cat'
        }
    ]
}

var personStr = JSON.stringify(person)
console.log(personStr)
console.log(typeof personStr) // string



  </script>
</head>
<body>
    
</body>
</html>